inline getprogname replacement
authorMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 Jan 2026 19:27:54 +0000 (22:27 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 24 Jan 2026 05:55:25 +0000 (08:55 +0300)
Forwarded: not-needed

Inline getprogname() by using program_invocation_short_name
when available (like with glibc).

This makes a lot of binaries to avoid linkage to libreplace.

This is a short and dirty version, proper change for upstream
should clean up #ifdef'fery in replace.c.

Gbp-Pq: Name inline-getprogname.diff

lib/replace/replace.c
lib/replace/replace.h

index d6b1383c2ea20cea62a5c149cf173bb79dd190aa..1d5f2eb7305755ba0fa8ab9b943338ede635f701 100644 (file)
@@ -983,7 +983,7 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count)
 }
 #endif /* HAVE_MEMSET_S */
 
-#ifndef HAVE_GETPROGNAME
+#if !defined(HAVE_GETPROGNAME) && !defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
 # ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
 # define PROGNAME_SIZE 32
 static char rep_progname[PROGNAME_SIZE];
index a67d9cc373a37d44861b1c8f737b2e761fc103d4..c7d7aca1d3a86ea1fce03f0b3de1697d1c9c07e6 100644 (file)
@@ -1005,9 +1005,13 @@ int rep_memset_s(void *dest, size_t destsz, int ch, size_t count);
 #endif
 
 #ifndef HAVE_GETPROGNAME
+#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+# define getprogname() (program_invocation_short_name)
+#else
 #define getprogname rep_getprogname
 const char *rep_getprogname(void);
 #endif
+#endif
 
 #ifndef HAVE_COPY_FILE_RANGE
 #define copy_file_range rep_copy_file_range